package com.demo.java.antlr;


import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;

import java.io.IOException;
import java.io.InputStream;

public class SqlBaseVisitorTest {
    public static void main(String[] args) throws IOException {
        String sql = "3*5+3\r\n(3+4)*4/5\r\na=1\r\nb=2\r\na+b*3";
//        SqlBaseLexer sqlBaseLexer = new SqlBaseLexer(new ANTLRInputStream(sql));
        SqlBaseLexer sqlBaseLexer = new SqlBaseLexer(CharStreams.fromString(sql));

//        InputStream is = System.in;
//        SqlBaseLexer sqlBaseLexer = new SqlBaseLexer(CharStreams.fromStream(is));

        SqlBaseParser parser = new SqlBaseParser(new CommonTokenStream(sqlBaseLexer));
        ParseTree prog = parser.prog();
        MySqlBaseVisitor visitor = new MySqlBaseVisitor();
        visitor.visit(prog);
    }
}
